package com.niren.relay.redis;

import redis.clients.jedis.Jedis;

import java.util.HashSet;
import java.util.Set;

public class RedisString implements RedisInterface {
    Jedis jedis = null;//new Jedis("localhost");

    public RedisString(String hostOrIp) {
        jedis = new Jedis(hostOrIp);
        jedis.select(0);
    }

    @Override
    public boolean setValue(String key, String value) {
        String result = jedis.set(key,value);
        return true;
    }

    @Override
    public String getValue(String key) {
        String jsonStr = jedis.get(key);
        return jsonStr;
    }

    @Override
    public boolean delValue(String key) {
        jedis.del(key);
        return true;
    }

    @Override
    public HashSet<String> getKeys(String rule) {
        return (HashSet<String>)jedis.keys(rule);
    }
}
